//二级目录导航点击切换
function leftNaviFunc(arr) {
    for (var i = 0; i < $('.left_part li').length; i++) {
        if ($('.left_part li').eq(i).hasClass('left_partActive')) {
            $(window.parent.document).find(".leftNavInfo").text($('.left_part li').eq(i).text());
        }
        (function(i) {
            $('.left_part li').eq(i).click(function() {
                $(this).addClass('left_partActive').siblings().removeClass('left_partActive');
                $(window.parent.document).find(".leftNavInfo").text($(this).text());
                $(window.parent.document).find("#mainFrame").removeAttr('src');
                $(window.parent.document).find("#mainFrame").attr('src', arr[i]);
            })
        }(i));
    }
}

//根元素的font-size设定rem
(function(doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function() {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            if (clientWidth >= 1920) {
                docEl.style.fontSize = '100px';
            } else {
                docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px';
            }
        };

    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

function http(url, type, data) {
    var ajaxObj = {
        "url": url,
        "type": 'get',
        "dataType": 'json',
    }
    if (type) {
        ajaxObj["type"] = type;
    }
    if (type == 'post' || type == 'put') {
        ajaxObj["contentType"] = "application/json";
        ajaxObj["data"] = JSON.stringify(data);
    }

    return $.ajax(ajaxObj)
}

function doSuccess(data) {
    var resp = {
        "code": data.retcode,
        "value": data.value,
        "desc": data.desc,
    };
    if (data.retcode == 1) {
        window.location.replace("/login.html")
        return resp
    }
    if (data.retcode != 0) {
        layer.msg(data.desc, { icon: 2 });
        return resp
    }
    return resp;
}

function doFail(a, b, c) {
    console.log(a, b, c);
    alert("error")
    return
}

function reConfirm(msg, operation) {
    layer.msg(msg, {
        time: 0,
        btn: ['确定', '取消'],
        yes: function(index) {
            layer.close(index);
            operation();
        }
    })
}